package com.xuexiang.xuidemo.slice;

import com.xuexiang.xuidemo.ResourceTable;
import com.xuexiang.xuidemo.slice.popupwindow.ViewTipAbilitySlice;
import com.xuexiang.xuidemo.slice.popupwindow.XToastAbilitySlice;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.DirectionalLayout;
import ohos.agp.components.Image;


/**
 * 弹出窗
 */
public class PopupWindowAbilitySlice extends AbilitySlice implements Component.ClickedListener {
    private Image image_back;
    private DirectionalLayout dl_one,dl_two,dl_three,dl_four,dl_five,dl_six,dl_seven;
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_popup_window);
        initComponent();
        initClickedListener();

    }

    public void  initComponent(){
        image_back=(Image) findComponentById(ResourceTable.Id_image_back);
        dl_one=(DirectionalLayout) findComponentById(ResourceTable.Id_dl_one);
        dl_two=(DirectionalLayout) findComponentById(ResourceTable.Id_dl_two);
        dl_three=(DirectionalLayout) findComponentById(ResourceTable.Id_dl_three);
        dl_four=(DirectionalLayout) findComponentById(ResourceTable.Id_dl_four);
        dl_five=(DirectionalLayout) findComponentById(ResourceTable.Id_dl_five);
        dl_six=(DirectionalLayout) findComponentById(ResourceTable.Id_dl_six);
        dl_seven=(DirectionalLayout) findComponentById(ResourceTable.Id_dl_seven);
    }
    private void initClickedListener() {
        image_back.setClickedListener(this);
        dl_one.setClickedListener(this);
        dl_two.setClickedListener(this);
        dl_three.setClickedListener(this);
        dl_four.setClickedListener(this);
        dl_five.setClickedListener(this);
        dl_six.setClickedListener(this);
        dl_seven.setClickedListener(this);
    }
    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }

    @Override
    public void onClick(Component component) {
        switch (component.getId()){
            case ResourceTable.Id_image_back:
                onBackPressed();
                break;
            case ResourceTable.Id_dl_one:
                present(new PopupWindowStyleSlice(), new Intent());
                break;
            case ResourceTable.Id_dl_two:
                present(new ViewTipAbilitySlice(), new Intent());
                break;
            case ResourceTable.Id_dl_three:
                present(new EasyPopSlice(), new Intent());
                break;
            case ResourceTable.Id_dl_four:
                present(new XulPopupSlice(), new Intent());
                break;
            case ResourceTable.Id_dl_five:
                present(new SnackbarSlice(), new Intent());
                break;
            case ResourceTable.Id_dl_six:
                present(new CookieBarSlice(), new Intent());
                break;
            case ResourceTable.Id_dl_seven:
                present(new XToastAbilitySlice(),new Intent());
                break;
        }
    }
}
